package com.kb.design.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kb.design.common.ApiResponse;
import com.kb.design.dto.CheckValueDTO;
import com.kb.design.service.CheckValueService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 检查结果表;(check_value)表控制层
 * @author : http://www.yonsum.com
 * @date : 2025-9-3
 */
@Tag(name = "检查结果表控制层接口")
@RestController
@RequestMapping("/check")
public class CheckValueController{
    @Resource
    private CheckValueService checkValueService;

    /**
     * 通过参数查询单条数据
     *
     * @return 实例对象
     */
    @Operation(summary = "通过ID查询单个对象")
    @Parameter(name = "id", description = "null")
    @PostMapping("/queryOne")
    public ResponseEntity<CheckValueDTO> queryByPara(@RequestBody CheckValueDTO checkValue){
        return ResponseEntity.ok(checkValueService.queryOne(checkValue));
    }

    /**
     * 分页查询
     *
     * @param checkValue 筛选条件
     * @return 查询结果
     */
    @Operation(summary = "分页查询")
    @PostMapping("/pageList")
    public ApiResponse pageList(@RequestBody CheckValueDTO checkValue){
        return ApiResponse.success(checkValueService.paginQuery(checkValue));
    }

    /**
     * 新增数据
     *
     * @param checkValue 实例对象
     * @return 实例对象
     */
    @Operation(summary = "新增数据")
    @PostMapping("/add")
    public ResponseEntity<CheckValueDTO> add(@RequestBody CheckValueDTO checkValue){
        return ResponseEntity.ok(checkValueService.insert(checkValue));
    }

    /**
     * 更新数据
     *
     * @param checkValue 实例对象
     * @return 实例对象
     */
    @Operation(summary = "更新数据")
    @PostMapping("/update")
    public ApiResponse update(@RequestBody CheckValueDTO checkValue){
        return ApiResponse.success(checkValueService.update(checkValue));
    }
    /**
     * 处理完成
     *
     * @param checkValue 实例对象
     * @return 实例对象
     */
    @Operation(summary = "更新数据")
    @PostMapping("/processing")
    public ApiResponse processing(@RequestBody CheckValueDTO checkValue){
        return ApiResponse.success(checkValueService.processing(checkValue));
    }
    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Operation(summary = "通过ID删除对象")
    @Parameter(name = "id", description = "null")
    @DeleteMapping("/byId/{id}")
    public ResponseEntity<Integer> deleteById(@PathVariable("id") long id){
        return ResponseEntity.ok(checkValueService.deleteById(id));
    }
}
